package com.ant.storage.controller;


import com.ant.storage.common.ResultPage;
import com.ant.storage.common.ResultVo;
import com.ant.storage.dto.CollectionYearDto;
import com.ant.storage.dto.ProductDto;
import com.ant.storage.handler.AntException;
import com.ant.storage.service.ICollectionYearService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-10-25
 */
@Api(tags = "行业接口")
@RestController
@RequestMapping("/product")
public class CollectionYearController {

    @Autowired
    ICollectionYearService yearService;

    @ApiOperation(value = "获取所有行业列表")
    @GetMapping("/list")
    public ResultVo list(){
        return ResultVo.success("ok",yearService.list());
    }

//    @ApiOperation(value = "根据ID获取用户", notes = "返回指定ID的用户信息")
//    @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    @GetMapping("/users/{id}")
//    public User getUserById(@PathVariable Long id) {
//        return userService.findById(id);
//    }     @ApiImplicitParam(name = "id", value = "企核算id", required = true,dataType = "Integer", paramType = "query")


    @ApiOperation(value = "获取通过企业id获取列表")
    @ApiImplicitParam(name = "id", value = "企业id", required = true,dataType = "Integer", paramType = "query")
    @GetMapping("/listById")
    public ResultVo listById(Integer id){
        if(id==null){
            throw new AntException("请输入企业id");
        }
        return ResultVo.success("ok",yearService.listById(id));
    }

    @ApiOperation(value = "保存行业信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody CollectionYearDto dto)
    {
        return ResultVo.success("添加成功",yearService.saveCollectionYear(dto));
    }

    @ApiOperation(value = "获取采集分页信息")
    @GetMapping("/listPage")
    public ResultPage listPage(ProductDto dto)
    {
        return ResultPage.success("查询成功",yearService.listPage(dto));
    }


}
